import {defineStore} from 'pinia'
export const useCounterStore = defineStore('counter', () => {
  // state
  const count = ref(0)

  // getter
  const doubleCount = computed(() => count.value * 2)

  // action
  function increment() {
    count.value++
  }

  // 注意：使用count和doubleCount时，直接解构会丢失响应式。如需保持响应式，要用storeToRefs()

  return { count, doubleCount, increment }
},{
  persist:true
})